const StudentService = require('../services/StudentService')

const StudentController = {
  add: async (req, res) => {
    const { username, major, classes, year } = req.body
    // console.log(req.body)
    await StudentService.add({ username: Number(username), major, classes: Number(classes), year: Number(year) })
    res.send({
      ActionType: 'OK'
    })
  },

  getList: async (req, res) => {
    const result = await StudentService.getList(req.params)
    res.send({
      ActionType: 'OK',
      data: result
    })
  },

  delList: async (req, res) => {
    // console.log(req.params.username)
    await StudentService.delList({
      username: req.params.username
    })
    res.send({
      ActionType: 'OK'
    })
  },

  putList: async (req, res) => {
    const result = await StudentService.putList(req.body)
    res.send({
      ActionType: 'OK'
    })
  },

  getScoreList: async (req, res) => {
    // console.log(req.params.major)
    const result = await StudentService.getScoreList(req.params)
    res.send({
      ActionType: 'OK',
      data: result
    })
  }
}

module.exports = StudentController
